package com.rs.statistics.Controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rs.statistics.dao.IMemberDao;
import com.rs.statistics.dto.MemberDto;
import com.rs.statistics.model.Member;
import com.rs.statistics.service.IMemberService;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/Member")
public class MemberController {
	@Resource
	private IMemberService memberService;
	@Resource
	private IMemberDao memberDao;
	@ApiOperation(value = "根据条件查询会员", notes = "根据条件查询会员")
	@PostMapping("findAll")
	public Map findMember(@RequestBody MemberDto dto) {
		return memberService.findAll(dto);

	}
	@ApiOperation(value = "添加会员",notes = "添加会员")
	@PostMapping("/add")
	public String add(@RequestBody Member member) {
		memberDao.save(member);
		return "添加成功";
		
	}
	@ApiOperation(value = "修改用户",notes = "修改用户")
	@PostMapping("update")
	public String update(@RequestBody Member member) {
		memberDao.save(member);
		return "修改成功";

	}
	@ApiOperation(value = "删除用户",notes = "删除用户")
	@GetMapping("{id}")
	public String del(int id) {
		memberDao.deleteById(id);
		return "删除成功";

	}
	
	@ApiOperation(value = "重置状态",notes = "重置状态")
	@PostMapping("status")
	public int status(@RequestBody int id,int status) {
		return memberDao.findByIdAndStatus(id,status);

	}
	
}
